
Import('env')

libgaleraxx_env = env.Clone()

# Include paths
libgaleraxx_env.Append(CPPPATH = Split('''
                                          #
                                          #/common
                                          #/galerautils/src
                                          #/gcache/src
                                          #/gcs/src
                                       '''))

libgaleraxx_srcs = [
    'mapped_buffer.cpp',
    'write_set.cpp',
    'data_set.cpp',
    'key_set.cpp',
    'write_set_ng.cpp',
    'trx_handle.cpp',
    'key_entry_os.cpp',
    'wsdb.cpp',
    'certification.cpp',
    'galera_service_thd.cpp',
    'wsrep_params.cpp',
    'replicator_smm_params.cpp',
    'gcs_action_source.cpp',
    'galera_info.cpp',
    'replicator.cpp',
    'ist.cpp',
    'gcs_dummy.cpp',
    'saved_state.cpp'
]

objs = libgaleraxx_env.Object(libgaleraxx_srcs)
env.Append(LIBGALERA_OBJS = libgaleraxx_env.SharedObject(libgaleraxx_srcs))

# Environment for multimaster library build
mmlib_env = libgaleraxx_env.Clone()
mmlib_env.Append(CPPFLAGS = ' -DGALERA_MULTIMASTER')
mmlib_env.Replace(SHOBJPREFIX = 'libmmgalera++-')

mmlib_srcs = [
    'replicator_smm.cpp',
    'replicator_str.cpp',
    'replicator_smm_stats.cpp'
]

mm_objs = mmlib_env.Object(mmlib_srcs)
env.Append(LIBMMGALERA_OBJS = mmlib_env.SharedObject(mmlib_srcs))

# Environment to compile provider unit (part of multimaster library)
# This is needed to hardcode version and revision
mmprovider_env = mmlib_env.Clone()
Import ('GALERA_VER', 'GALERA_REV')
mmprovider_env.Append(CPPFLAGS = ' -DGALERA_VER=\\"' + GALERA_VER + '\\"')
mmprovider_env.Append(CPPFLAGS = ' -DGALERA_REV=\\"' + GALERA_REV + '\\"')

mmprovider_srcs = [
    'wsrep_provider.cpp'
]

mm_objs += mmprovider_env.Object(mmprovider_srcs)
env.Append(LIBMMGALERA_OBJS = mmprovider_env.SharedObject(mmprovider_srcs))

libgaleraxx_env.StaticLibrary('galera++', objs + mm_objs)

